package com.lagou.edu;

import com.lagou.edu.consumer.RpcConsumer;
import com.lagou.edu.pojo.User;
import com.lagou.edu.service.UserService;
import com.lagou.edu.timer.ReportServer;

import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * @author 赵虎
 * @date 2020/11/25 13:53
 */
public class ClientBootstrap {


    public static void main(String[] args) throws Exception {
        ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();

        ReportServer reportServer = new ReportServer(UserService.class.getName());

        scheduledExecutorService.scheduleAtFixedRate(reportServer, 0, 5, TimeUnit.SECONDS);

        RpcConsumer rpcConsumer = new RpcConsumer();

        UserService userService = (UserService) rpcConsumer.createProxy(UserService.class);
        for (; ; ) {
            Thread.sleep(1000);
            User user = new User();
            user.setUsername("zhangsan");
            user.setAge(18);
            userService.sayHello(user);
            userService.getUserList(18);
        }
    }
}
